package com.tencreat.service.pt.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.pt.MallPtBonusPool;
import com.tencreat.mapper.pt.MallPtBonusPoolMapper;
import com.tencreat.service.pt.IMallPtBonusPoolService;
import org.springframework.stereotype.Service;

/**
 * 奖金池Service业务层处理
 *
 * @author wangkai
 * @date 2021-11-30
 */
@Service
public class MallPtBonusPoolServiceImpl extends ServiceImpl<MallPtBonusPoolMapper, MallPtBonusPool> implements IMallPtBonusPoolService {


    /**
     * 查询奖金池
     *
     * @param id 奖金池ID
     * @return 奖金池
     */
    @Override
    public MallPtBonusPool selectMallPtBonusPoolById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询奖金池列表
     *
     * @param mallPtBonusPool 奖金池
     * @return 奖金池
     */
    @Override
    public List<MallPtBonusPool> selectMallPtBonusPoolList(MallPtBonusPool mallPtBonusPool) {
        return baseMapper.selectList(Wrappers.query(mallPtBonusPool));
    }

    /**
     * 新增奖金池
     *
     * @param mallPtBonusPool 奖金池
     * @return 结果
     */
    @Override
    public int insertMallPtBonusPool(MallPtBonusPool mallPtBonusPool) {
        mallPtBonusPool.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallPtBonusPool);
    }

    /**
     * 修改奖金池
     *
     * @param mallPtBonusPool 奖金池
     * @return 结果
     */
    @Override
    public int updateMallPtBonusPool(MallPtBonusPool mallPtBonusPool) {
        mallPtBonusPool.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallPtBonusPool);
    }

    /**
     * 批量删除奖金池
     *
     * @param ids 需要删除的奖金池ID
     * @return 结果
     */
    @Override
    public int deleteMallPtBonusPoolByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除奖金池信息
     *
     * @param id 奖金池ID
     * @return 结果
     */
    @Override
    public int deleteMallPtBonusPoolById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
